<html><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>{$txt['dowith']}</title>
    <link rel="stylesheet" href="{RES}css/weui.css">
    <link rel="stylesheet" href="{RES}css/kouhong.css?v={TIMESTAMP}">
	<link rel="stylesheet" href="{RES}css/layer.css?v=3.0.3303" id="layuicss-skinlayercss">
<style>
.lists{
	width:100%;
	height:auto;
}
.top_img{
	width:30%;
	margin:50px 35% 20px 35%
	;
}
.with_title,.money_tip,.i-tip{
	width:100%;
	height:auto;
	line-height:24px;
	font-size:14px;
	color:{$cfg['fcolor']};
	text-align:center;
}
.width_money{
	width:100%;
	height:50px;
	line-height:50px;
	font-size:14px;
	color:{$cfg['fcolor']};
	text-align:center;
}
.width_money>span{
	font-size:24px;
}
.money_tip{
	color:{$cfg['color']};
}
.with_btn{
	width:40%;
	height:40px;
	line-height:40px;
	margin: 15px 30%;
	border-radius:40px;
	background:{$cfg['color']};
	display:block;
	text-align:center;
	color:#fff;
}
.i-tip{
	width:80%;
	margin:0 10%;
	font-size:12px;
}
.withpic{
	width: 100%;
    display: block;
    text-align: center;
    margin-top: 10px;
}
.withpic>img{
	width:30%;
}
</style>
</head>

<body style="--wx_color:{$cfg['color']};--wx_color1:{$cfg['color1']};--wx_color2:{$cfg['color2']};--wx_fcolor:{$cfg['fcolor']};--wx_fcolor1:{$cfg['fcolor1']};">

<img class="top_img" src="{$face['hongbao']}" />
<div class="with_title">{$txt['reback']}</div>
<div class="width_money">
	￥<span>{$mem['red']}</span>（实际到账：{$real}）
</div>
{if $cfg['commission']['with']>0}<div class="money_tip">金额达到{$cfg['commission']['with']}元方可提现</div>{/if}
{if $mem['red'] >= $cfg['commission']['with'] && $mem['red'] > 0}
{if $cfg['commission']['wx_switch'] == 1}
<div class="i-tip">{$cfg['commission']['wx_tips']}</div>
<span class="withpic">
	<img id="previewImg" onclick="chooseImg();" src="{if !empty($mem['qr'])}{$mem['qr']}{else}{php echo toimage($cfg['face']['app_add'])}{/if}" />
</span>
{/if}
<a class="with_btn" onclick="goWith();">提现</a>
{/if}
{if !empty($cfg['commission']['tips'])}<div class="i-tip" style="color:{$cfg['color']};">{$cfg['commission']['tips']}</div>{/if}
{if $cfg['commission']['wrate']>0}<div class="i-tip">平台将收取{$cfg['commission']['wrate']}%的服务费</div>{/if}
{if $cfg['commission']['withnum']>0}<div class="i-tip">每日最多可提现{$cfg['commission']['withnum']}次</div>{/if}
{template 'footer'}
<script src="{RES}js/jquery-3.2.1.min.js"></script>
<script src="{RES}js/layer.js"></script>
{template 'jsweixin'}
<script>
{if empty($mem['qr'])}
var qrPic = '';
{else}
var qrPic = "{$mem['qr']}";
{/if}
var localId = '';
function chooseImg(){
	wx.chooseImage({
		count : 1, // 默认9
		success : function(res) {
			var selThumb = res.localIds[0];
	    	localId = selThumb;
			$("#previewImg").attr("src", localId);
		}
	});
}
function fileUpload(){
	if(localId=='') return false;
	wx.uploadImage({
		localId : localId, // 需要上传的图片的本地ID，由chooseImage接口获得
		isShowProgressTips : 1, // 默认为1，显示进度提示
		success : function(res) {
			$.ajax({
				type:"POST",
				url:"{php echo $this->createMobileUrl('uploadpic')}",
				data:{imgid:res.serverId},
				cache:false,
				success:function(data){
					data = JSON.parse(data);
					if(data.code==-1){
						layer.msg(data.msg);
					}
					else{
						localId = '';
						$("#previewImg").attr("src", data.url);
						qrPic = data.url;
						goWith();
					}
				}
			});
		}
	});
}
var isSubmit = false;
var defaultPic = "{php echo toimage($cfg['face']['app_add'])}";
function goWith(){
	{if $cfg['commission']['wx_switch'] == 1}
	if(localId == '' && qrPic == ''){
		layer.msg('请上传微信收款码');
		return false;
	}
	if(qrPic=='' || localId){
		fileUpload();
		return false;
	}
	{/if}
	{if $mem['red'] <= 0}
	layer.msg('暂无可提现金额');
	return false;
	{/if}
	{if $mem['red'] < $cfg['commission']['with']}
	layer.msg('未达到最低提现金额');
	return false;
	{/if}
	if(!confirm('确认要提现吗？')){
		return false;
	}
	if(isSubmit) return false;
	var layerIndex = layer.load(2, {shade: 0.3}); 
	$.ajax({
		type:'post',
		url:"{php echo $this->createMobileUrl('dowith',array('openid'=>$_W['openid']));}",
		data:{qrPic: qrPic},
		success:function(data){
			isSubmit = false;
			layer.close(layerIndex); 
			data = JSON.parse(data);
			if(data.status==1){
				layer.alert(data.msg, {
				  skin: 'layui-layer-molv' //样式类名
				  ,closeBtn: 0
				}, function(){
					var layerIndex = layer.load(2, {shade: 0.3}); 
					var url = "{php echo $this->createMobileUrl('my');}";
					location.href = url;
					layer.close(layerIndex); 
				});
			}
			else{
				layer.msg(data.msg);
			}
		}
		,error:function(){
			layer.msg('网络错误，请刷新重试');
		}
	});
}
</script>

</body>
</html>